<?php
declare (strict_types = 1);

namespace app\common\listener\Notification;
use app\common\service\NotificationService;
class Listen
{
    /**
     * 事件监听处理
     *
     * @return mixed
     */
    public function handle($event)
    {
        $service = new NotificationService;
       list($response , $notify , $request) = $event;
       $toMessage = [];
       if(empty($notify->message))
       {
           $toMessage = [
               'title'      =>  $notify->title,
               'message'    =>  $response->getData()['message'] ?? $notify->title,
               'return_msg' =>  $response->getData(),
               'method'     =>  $request->method(),
               'url'        =>  $request->baseUrl()
           ];
       }

       switch ($request->method())
       {
           case 'GET':
           case 'DELETE':
               $toMessage["params"] =  $request->param();
           case 'POST':
               $toMessage["params"] =  $request->post();
           case 'PUT':
               $toMessage["params"] =  $request->put();

       }

    }
}
